from rest_framework import serializers
from . import models

class CourseCategoryModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.CourseCategory
        fields = ['id','name']


class TeacherModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Teacher
        fields = ['name','title','signature']



class CourseModelSerializer(serializers.ModelSerializer):
    """展示课程详细信息的序列化器"""
    teacher = TeacherModelSerializer()
    class Meta:
        model = models.Course
        fields = ["id", "name", "course_img", "students", "lessons", "pub_lessons", "price",'teacher','lesson_list']